/*
 * @Description: 
 * @Author: Leequik
 * @Date: 2025-06-11 11:51:36
 * @LastEditTime: 2025-06-26 11:24:37
 * @LastEditors: Leequik
 */
import { reactive,getCurrentInstance } from 'vue';
import axios from 'axios';
import $http from '../api/request.ts';

export default function () { //暴露数据源
    let dogList = reactive([
        'https://images.dog.ceo/breeds/pembroke/n02113023_4373.jpg'
    ])
    
/*    async function getDog() {
        try {
            let res = await axios.get('/dog_img');
            console.log(res);
            dogList.push(res.data.message);
        } catch (error) {
            console.log(error);
       
        }   
    }
    */
    const  { proxy} = getCurrentInstance()
    async function getDog() {
        
        //let res = proxy.$axios.get('/dog_img');
        /*
        let res = await axios.get('/dog_img').then(res=>{
            console.log(res);
        }).catch(error=>{
            console.log(error);
        })

        
        $http.get('/' ).then(res=>{
            console.log(res.data);
        }).catch(error=>{
            console.log(error);
        })

        */
        
        proxy.$axios.get('/api').then(res=>{ 
            console.log(res.data);
            dogList.push(res.data.message)
        }).catch(error=>{
            console.log(error);
        })
       
    }   
    
    //向外部提供数据
    return { dogList, getDog }
}


